$(function(){
   var buildingId=$.getUrlVar('buildingId');

    $.get("/index.php?m=Admin&c=building&a=read&id="+buildingId,function(data){
      var str="";
      console.log(data);
      $(".building_name").attr("value",data.data.full_parent_name+data.data.name);
      $(".building_id").attr("value",data.data.id);
    });
    
    $("#form-unit-add").Validform({
    tiptype:2,
    ajaxPost:true,
    showAllError:true,
    beforeSubmit:function(curform){
      curform.ajaxSubmit({
        type:'POST',
        url:'/index.php?m=Admin&c=Unit&a=add',
        success:function(data){
              if(data.stat==1){
                   layer.msg("添加成功");
                  var index = parent.layer.getFrameIndex(window.name);
                  setTimeout(function(){
                         parent.layer.close(index);
                  },1000);
                   parent.location.reload();
               }else{
                 layer.msg(data.msg);
               }
             
              }
        });
      return false;
    }
  });
});